#include "huffman_tree.h"
#include <stdio.h>

#define LEAVE 26 // 假如对26个大写字符进行哈夫曼编码

const double weight[LEAVE] = {
    0.0856, 0.0139, 0.0297, 0.0378, 0.1304, 0.0289, 0.0199, 0.0528, 0.0627,
    0.0013, 0.0042, 0.0339, 0.0249, 0.0707, 0.0797, 0.0199, 0.0012, 0.0677,
    0.0607, 0.1045, 0.0249, 0.0092, 0.0149, 0.0017, 0.0199, 0.0008};

int main() {
  hf_tree t = huffman_create(weight, LEAVE);

  // 存放编码字符串
  char *encoding[LEAVE];

  huf_code(t, encoding, LEAVE);

  for (int i = 0; i < LEAVE; i++)
    printf("The character %c encoding is: %s\n", 'A' + i, encoding[i]);

  huffman_destory(t);
  return 0;
}
